﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Threading;

namespace RiskMan.Views.Stop
{
    public partial class StopView
    {
        private DispatcherTimer _dsTimer = new DispatcherTimer();

        private void StopsLayout_Loaded(object sender, RoutedEventArgs e)
        {
            _dsTimer.Interval = TimeSpan.FromMilliseconds(1000);
            _dsTimer.Start();
            _dsTimer.Tick += new EventHandler(_dsTimer_Tick);
        }

        public void _dsTimer_Tick(Object sender, EventArgs args)
        {
            bool running;

            running = mainWindow.ConnectingOrDisconnecting();

            BtnCheckStart.IsEnabled = running;
            BtnStopCheck.IsEnabled = running;

            if (running == true)
            {
                if (mainWindow._dataProvider.StopList.Count > 0)
                {
                    foreach (var item in mainWindow._dataProvider.StopList)
                    {
                        if (item.IsStart == true)
                        {
                            LogikStops logikStops = new LogikStops(mainWindow);
                            logikStops.Start(item);
                        }
                    }

                }
            }
        }
    }
}
